<!DOCTYPE HTML>

<html lang="en">
<head>

<title>User (spring-security-docs 5.6.3 API)</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link rel="stylesheet" type="text/css" href="../../../../../stylesheet.css" title="Style">
<link rel="stylesheet" type="text/css" href="../../../../../jquery/jquery-ui.css" title="Style">
<script type="text/javascript" src="../../../../../script.js"></script>
<script type="text/javascript" src="../../../../../jquery/jszip/dist/jszip.min.js"></script>
<script type="text/javascript" src="../../../../../jquery/jszip-utils/dist/jszip-utils.min.js"></script>
<!--[if IE]>
<script type="text/javascript" src="../../../../../jquery/jszip-utils/dist/jszip-utils-ie.min.js"></script>
<![endif]-->
<script type="text/javascript" src="../../../../../jquery/jquery-3.5.1.js"></script>
<script type="text/javascript" src="../../../../../jquery/jquery-ui.js"></script>
</head>
<body>
<script type="text/javascript"><!--
    try {
        if (location.href.indexOf('is-external=true') == -1) {
            parent.document.title="User (spring-security-docs 5.6.3 API)";
        }
    }
    catch(err) {
    }
//-->
var data = {"i0":9,"i1":10,"i2":10,"i3":10,"i4":10,"i5":10,"i6":10,"i7":10,"i8":10,"i9":10,"i10":10,"i11":10,"i12":41,"i13":9,"i14":9};
var tabs = {65535:["t0","All Methods"],1:["t1","Static Methods"],2:["t2","Instance Methods"],8:["t4","Concrete Methods"],32:["t6","Deprecated Methods"]};
var altColor = "altColor";
var rowColor = "rowColor";
var tableTab = "tableTab";
var activeTableTab = "activeTableTab";
var pathtoroot = "../../../../../";
var useModuleDirectories = true;
loadScripts(document, 'script');</script>
<noscript>
<div>JavaScript is disabled on your browser.</div>
</noscript>
<header role="banner">
<nav role="navigation">
<div class="fixedNav">

<div class="topNav"><a id="navbar.top">

</a>
<div class="skipNav"><a href="User.html#skip.navbar.top" title="Skip navigation links">Skip navigation links</a></div>
<a id="navbar.top.firstrow">

</a>
<ul class="navList" title="Navigation">
<li><a href="../../../../../index.html">Overview</a></li>
<li><a href="package-summary.html">Package</a></li>
<li class="navBarCell1Rev">Class</li>
<li><a href="package-tree.html">Tree</a></li>
<li><a href="../../../../../deprecated-list.html">Deprecated</a></li>
<li><a href="../../../../../index-all.html">Index</a></li>
<li><a href="../../../../../help-doc.html">Help</a></li>
</ul>
</div>
<div class="subNav">
<ul class="navList" id="allclasses_navbar_top">
<li><a href="../../../../../allclasses.html">All&nbsp;Classes</a></li>
</ul>
<ul class="navListSearch">
<li><label for="search">SEARCH:</label>
<input type="text" id="search" value="search" disabled="disabled">
<input type="reset" id="reset" value="reset" disabled="disabled">
</li>
</ul>
<div>
<script type="text/javascript"><!--
  allClassesLink = document.getElementById("allclasses_navbar_top");
  if(window==top) {
    allClassesLink.style.display = "block";
  }
  else {
    allClassesLink.style.display = "none";
  }
  //-->
</script>
<noscript>
<div>JavaScript is disabled on your browser.</div>
</noscript>
</div>
<div>
<ul class="subNavList">
<li>Summary:&nbsp;</li>
<li><a href="User.html#nested.class.summary">Nested</a>&nbsp;|&nbsp;</li>
<li>Field&nbsp;|&nbsp;</li>
<li><a href="User.html#constructor.summary">Constr</a>&nbsp;|&nbsp;</li>
<li><a href="User.html#method.summary">Method</a></li>
</ul>
<ul class="subNavList">
<li>Detail:&nbsp;</li>
<li>Field&nbsp;|&nbsp;</li>
<li><a href="User.html#constructor.detail">Constr</a>&nbsp;|&nbsp;</li>
<li><a href="User.html#method.detail">Method</a></li>
</ul>
</div>
<a id="skip.navbar.top">

</a></div>

</div>
<div class="navPadding">&nbsp;</div>
<script type="text/javascript"><!--
$('.navPadding').css('padding-top', $('.fixedNav').css("height"));
//-->
</script>
</nav>
</header>

<main role="main">
<div class="header">
<div class="subTitle"><span class="packageLabelInType">Package</span>&nbsp;<a href="package-summary.html">org.springframework.security.core.userdetails</a></div>
<h2 title="Class User" class="title">Class User</h2>
</div>
<div class="contentContainer">
<ul class="inheritance">
<li>java.lang.Object</li>
<li>
<ul class="inheritance">
<li>org.springframework.security.core.userdetails.User</li>
</ul>
</li>
</ul>
<div class="description">
<ul class="blockList">
<li class="blockList">
<dl>
<dt>All Implemented Interfaces:</dt>
<dd><code>java.io.Serializable</code>, <code><a href="../CredentialsContainer.html" title="interface in org.springframework.security.core">CredentialsContainer</a></code>, <code><a href="UserDetails.html" title="interface in org.springframework.security.core.userdetails">UserDetails</a></code></dd>
</dl>
<hr>
<pre>public class <span class="typeNameLabel">User</span>
extends java.lang.Object
implements <a href="UserDetails.html" title="interface in org.springframework.security.core.userdetails">UserDetails</a>, <a href="../CredentialsContainer.html" title="interface in org.springframework.security.core">CredentialsContainer</a></pre>
<div class="block">Models core user information retrieved by a <a href="UserDetailsService.html" title="interface in org.springframework.security.core.userdetails"><code>UserDetailsService</code></a>.
<p>
Developers may use this class directly, subclass it, or write their own
<a href="UserDetails.html" title="interface in org.springframework.security.core.userdetails"><code>UserDetails</code></a> implementation from scratch.
<p>
<code>equals</code> and <code>hashcode</code> implementations are based on the <code>username</code>
property only, as the intention is that lookups of the same user principal object (in a
user registry, for example) will match where the objects represent the same user, not
just when all the properties (authorities, password for example) are the same.
<p>
Note that this implementation is not immutable. It implements the
<code>CredentialsContainer</code> interface, in order to allow the password to be erased
after authentication. This may cause side-effects if you are storing instances
in-memory and reusing them. If so, make sure you return a copy from your
<code>UserDetailsService</code> each time it is invoked.</div>
<dl>
<dt><span class="seeLabel">See Also:</span></dt>
<dd><a href="../../../../../serialized-form.html#org.springframework.security.core.userdetails.User">Serialized Form</a></dd>
</dl>
</li>
</ul>
</div>
<div class="summary">
<ul class="blockList">
<li class="blockList">

<section role="region">
<ul class="blockList">
<li class="blockList"><a id="nested.class.summary">

</a>
<h3>Nested Class Summary</h3>
<table class="memberSummary">
<caption><span>Nested Classes</span><span class="tabEnd">&nbsp;</span></caption>
<tr>
<th class="colFirst" scope="col">Modifier and Type</th>
<th class="colSecond" scope="col">Class</th>
<th class="colLast" scope="col">Description</th>
</tr>
<tr class="altColor">
<td class="colFirst"><code>static class&nbsp;</code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="User.UserBuilder.html" title="class in org.springframework.security.core.userdetails">User.UserBuilder</a></span></code></th>
<td class="colLast">
<div class="block">Builds the user to be added.</div>
</td>
</tr>
</table>
</li>
</ul>
</section>

<section role="region">
<ul class="blockList">
<li class="blockList"><a id="constructor.summary">

</a>
<h3>Constructor Summary</h3>
<table class="memberSummary">
<caption><span>Constructors</span><span class="tabEnd">&nbsp;</span></caption>
<tr>
<th class="colFirst" scope="col">Constructor</th>
<th class="colLast" scope="col">Description</th>
</tr>
<tr class="altColor">
<th class="colConstructorName" scope="row"><code><span class="memberNameLink"><a href="User.html#%3Cinit%3E(java.lang.String,java.lang.String,boolean,boolean,boolean,boolean,java.util.Collection)">User</a></span>&#8203;(java.lang.String&nbsp;username,
java.lang.String&nbsp;password,
boolean&nbsp;enabled,
boolean&nbsp;accountNonExpired,
boolean&nbsp;credentialsNonExpired,
boolean&nbsp;accountNonLocked,
java.util.Collection&lt;? extends <a href="../GrantedAuthority.html" title="interface in org.springframework.security.core">GrantedAuthority</a>&gt;&nbsp;authorities)</code></th>
<td class="colLast">
<div class="block">Construct the <code>User</code> with the details required by
<a href="../../authentication/dao/DaoAuthenticationProvider.html" title="class in org.springframework.security.authentication.dao"><code>DaoAuthenticationProvider</code></a>.</div>
</td>
</tr>
<tr class="rowColor">
<th class="colConstructorName" scope="row"><code><span class="memberNameLink"><a href="User.html#%3Cinit%3E(java.lang.String,java.lang.String,java.util.Collection)">User</a></span>&#8203;(java.lang.String&nbsp;username,
java.lang.String&nbsp;password,
java.util.Collection&lt;? extends <a href="../GrantedAuthority.html" title="interface in org.springframework.security.core">GrantedAuthority</a>&gt;&nbsp;authorities)</code></th>
<td class="colLast">
<div class="block">Calls the more complex constructor with all boolean arguments set to <code>true</code>.</div>
</td>
</tr>
</table>
</li>
</ul>
</section>

<section role="region">
<ul class="blockList">
<li class="blockList"><a id="method.summary">

</a>
<h3>Method Summary</h3>
<table class="memberSummary">
<caption><span id="t0" class="activeTableTab"><span>All Methods</span><span class="tabEnd">&nbsp;</span></span><span id="t1" class="tableTab"><span><a href="javascript:show(1);">Static Methods</a></span><span class="tabEnd">&nbsp;</span></span><span id="t2" class="tableTab"><span><a href="javascript:show(2);">Instance Methods</a></span><span class="tabEnd">&nbsp;</span></span><span id="t4" class="tableTab"><span><a href="javascript:show(8);">Concrete Methods</a></span><span class="tabEnd">&nbsp;</span></span><span id="t6" class="tableTab"><span><a href="javascript:show(32);">Deprecated Methods</a></span><span class="tabEnd">&nbsp;</span></span></caption>
<tr>
<th class="colFirst" scope="col">Modifier and Type</th>
<th class="colSecond" scope="col">Method</th>
<th class="colLast" scope="col">Description</th>
</tr>
<tr id="i0" class="altColor">
<td class="colFirst"><code>static <a href="User.UserBuilder.html" title="class in org.springframework.security.core.userdetails">User.UserBuilder</a></code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="User.html#builder()">builder</a></span>()</code></th>
<td class="colLast">
<div class="block">Creates a UserBuilder</div>
</td>
</tr>
<tr id="i1" class="rowColor">
<td class="colFirst"><code>boolean</code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="User.html#equals(java.lang.Object)">equals</a></span>&#8203;(java.lang.Object&nbsp;obj)</code></th>
<td class="colLast">
<div class="block">Returns <code>true</code> if the supplied object is a <code>User</code> instance with the
same <code>username</code> value.</div>
</td>
</tr>
<tr id="i2" class="altColor">
<td class="colFirst"><code>void</code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="User.html#eraseCredentials()">eraseCredentials</a></span>()</code></th>
<td class="colLast">&nbsp;</td>
</tr>
<tr id="i3" class="rowColor">
<td class="colFirst"><code>java.util.Collection&lt;<a href="../GrantedAuthority.html" title="interface in org.springframework.security.core">GrantedAuthority</a>&gt;</code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="User.html#getAuthorities()">getAuthorities</a></span>()</code></th>
<td class="colLast">
<div class="block">Returns the authorities granted to the user.</div>
</td>
</tr>
<tr id="i4" class="altColor">
<td class="colFirst"><code>java.lang.String</code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="User.html#getPassword()">getPassword</a></span>()</code></th>
<td class="colLast">
<div class="block">Returns the password used to authenticate the user.</div>
</td>
</tr>
<tr id="i5" class="rowColor">
<td class="colFirst"><code>java.lang.String</code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="User.html#getUsername()">getUsername</a></span>()</code></th>
<td class="colLast">
<div class="block">Returns the username used to authenticate the user.</div>
</td>
</tr>
<tr id="i6" class="altColor">
<td class="colFirst"><code>int</code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="User.html#hashCode()">hashCode</a></span>()</code></th>
<td class="colLast">
<div class="block">Returns the hashcode of the <code>username</code>.</div>
</td>
</tr>
<tr id="i7" class="rowColor">
<td class="colFirst"><code>boolean</code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="User.html#isAccountNonExpired()">isAccountNonExpired</a></span>()</code></th>
<td class="colLast">
<div class="block">Indicates whether the user's account has expired.</div>
</td>
</tr>
<tr id="i8" class="altColor">
<td class="colFirst"><code>boolean</code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="User.html#isAccountNonLocked()">isAccountNonLocked</a></span>()</code></th>
<td class="colLast">
<div class="block">Indicates whether the user is locked or unlocked.</div>
</td>
</tr>
<tr id="i9" class="rowColor">
<td class="colFirst"><code>boolean</code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="User.html#isCredentialsNonExpired()">isCredentialsNonExpired</a></span>()</code></th>
<td class="colLast">
<div class="block">Indicates whether the user's credentials (password) has expired.</div>
</td>
</tr>
<tr id="i10" class="altColor">
<td class="colFirst"><code>boolean</code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="User.html#isEnabled()">isEnabled</a></span>()</code></th>
<td class="colLast">
<div class="block">Indicates whether the user is enabled or disabled.</div>
</td>
</tr>
<tr id="i11" class="rowColor">
<td class="colFirst"><code>java.lang.String</code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="User.html#toString()">toString</a></span>()</code></th>
<td class="colLast">&nbsp;</td>
</tr>
<tr id="i12" class="altColor">
<td class="colFirst"><code>static <a href="User.UserBuilder.html" title="class in org.springframework.security.core.userdetails">User.UserBuilder</a></code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="User.html#withDefaultPasswordEncoder()">withDefaultPasswordEncoder</a></span>()</code></th>
<td class="colLast">
<div class="block"><span class="deprecatedLabel">Deprecated.</span>
<div class="deprecationComment">Using this method is not considered safe for production, but is
acceptable for demos and getting started.</div>
</div>
</td>
</tr>
<tr id="i13" class="rowColor">
<td class="colFirst"><code>static <a href="User.UserBuilder.html" title="class in org.springframework.security.core.userdetails">User.UserBuilder</a></code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="User.html#withUserDetails(org.springframework.security.core.userdetails.UserDetails)">withUserDetails</a></span>&#8203;(<a href="UserDetails.html" title="interface in org.springframework.security.core.userdetails">UserDetails</a>&nbsp;userDetails)</code></th>
<td class="colLast">&nbsp;</td>
</tr>
<tr id="i14" class="altColor">
<td class="colFirst"><code>static <a href="User.UserBuilder.html" title="class in org.springframework.security.core.userdetails">User.UserBuilder</a></code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="User.html#withUsername(java.lang.String)">withUsername</a></span>&#8203;(java.lang.String&nbsp;username)</code></th>
<td class="colLast">
<div class="block">Creates a UserBuilder with a specified user name</div>
</td>
</tr>
</table>
<ul class="blockList">
<li class="blockList"><a id="methods.inherited.from.class.java.lang.Object">

</a>
<h3>Methods inherited from class&nbsp;java.lang.Object</h3>
<code>clone, finalize, getClass, notify, notifyAll, wait, wait, wait</code></li>
</ul>
</li>
</ul>
</section>
</li>
</ul>
</div>
<div class="details">
<ul class="blockList">
<li class="blockList">

<section role="region">
<ul class="blockList">
<li class="blockList"><a id="constructor.detail">

</a>
<h3>Constructor Detail</h3>
<a id="&lt;init&gt;(java.lang.String,java.lang.String,java.util.Collection)">

</a>
<ul class="blockList">
<li class="blockList">
<h4>User</h4>
<pre>public&nbsp;User&#8203;(java.lang.String&nbsp;username,
            java.lang.String&nbsp;password,
            java.util.Collection&lt;? extends <a href="../GrantedAuthority.html" title="interface in org.springframework.security.core">GrantedAuthority</a>&gt;&nbsp;authorities)</pre>
<div class="block">Calls the more complex constructor with all boolean arguments set to <code>true</code>.</div>
</li>
</ul>
<a id="&lt;init&gt;(java.lang.String,java.lang.String,boolean,boolean,boolean,boolean,java.util.Collection)">

</a>
<ul class="blockListLast">
<li class="blockList">
<h4>User</h4>
<pre>public&nbsp;User&#8203;(java.lang.String&nbsp;username,
            java.lang.String&nbsp;password,
            boolean&nbsp;enabled,
            boolean&nbsp;accountNonExpired,
            boolean&nbsp;credentialsNonExpired,
            boolean&nbsp;accountNonLocked,
            java.util.Collection&lt;? extends <a href="../GrantedAuthority.html" title="interface in org.springframework.security.core">GrantedAuthority</a>&gt;&nbsp;authorities)</pre>
<div class="block">Construct the <code>User</code> with the details required by
<a href="../../authentication/dao/DaoAuthenticationProvider.html" title="class in org.springframework.security.authentication.dao"><code>DaoAuthenticationProvider</code></a>.</div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>username</code> - the username presented to the
<code>DaoAuthenticationProvider</code></dd>
<dd><code>password</code> - the password that should be presented to the
<code>DaoAuthenticationProvider</code></dd>
<dd><code>enabled</code> - set to <code>true</code> if the user is enabled</dd>
<dd><code>accountNonExpired</code> - set to <code>true</code> if the account has not expired</dd>
<dd><code>credentialsNonExpired</code> - set to <code>true</code> if the credentials have not
expired</dd>
<dd><code>accountNonLocked</code> - set to <code>true</code> if the account is not locked</dd>
<dd><code>authorities</code> - the authorities that should be granted to the caller if they
presented the correct username and password and the user is enabled. Not null.</dd>
<dt><span class="throwsLabel">Throws:</span></dt>
<dd><code>java.lang.IllegalArgumentException</code> - if a <code>null</code> value was passed either as
a parameter or as an element in the <code>GrantedAuthority</code> collection</dd>
</dl>
</li>
</ul>
</li>
</ul>
</section>

<section role="region">
<ul class="blockList">
<li class="blockList"><a id="method.detail">

</a>
<h3>Method Detail</h3>
<a id="getAuthorities()">

</a>
<ul class="blockList">
<li class="blockList">
<h4>getAuthorities</h4>
<pre class="methodSignature">public&nbsp;java.util.Collection&lt;<a href="../GrantedAuthority.html" title="interface in org.springframework.security.core">GrantedAuthority</a>&gt;&nbsp;getAuthorities()</pre>
<div class="block"><span class="descfrmTypeLabel">Description copied from interface:&nbsp;<code><a href="UserDetails.html#getAuthorities()">UserDetails</a></code></span></div>
<div class="block">Returns the authorities granted to the user. Cannot return <code>null</code>.</div>
<dl>
<dt><span class="overrideSpecifyLabel">Specified by:</span></dt>
<dd><code><a href="UserDetails.html#getAuthorities()">getAuthorities</a></code>&nbsp;in interface&nbsp;<code><a href="UserDetails.html" title="interface in org.springframework.security.core.userdetails">UserDetails</a></code></dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>the authorities, sorted by natural key (never <code>null</code>)</dd>
</dl>
</li>
</ul>
<a id="getPassword()">

</a>
<ul class="blockList">
<li class="blockList">
<h4>getPassword</h4>
<pre class="methodSignature">public&nbsp;java.lang.String&nbsp;getPassword()</pre>
<div class="block"><span class="descfrmTypeLabel">Description copied from interface:&nbsp;<code><a href="UserDetails.html#getPassword()">UserDetails</a></code></span></div>
<div class="block">Returns the password used to authenticate the user.</div>
<dl>
<dt><span class="overrideSpecifyLabel">Specified by:</span></dt>
<dd><code><a href="UserDetails.html#getPassword()">getPassword</a></code>&nbsp;in interface&nbsp;<code><a href="UserDetails.html" title="interface in org.springframework.security.core.userdetails">UserDetails</a></code></dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>the password</dd>
</dl>
</li>
</ul>
<a id="getUsername()">

</a>
<ul class="blockList">
<li class="blockList">
<h4>getUsername</h4>
<pre class="methodSignature">public&nbsp;java.lang.String&nbsp;getUsername()</pre>
<div class="block"><span class="descfrmTypeLabel">Description copied from interface:&nbsp;<code><a href="UserDetails.html#getUsername()">UserDetails</a></code></span></div>
<div class="block">Returns the username used to authenticate the user. Cannot return
<code>null</code>.</div>
<dl>
<dt><span class="overrideSpecifyLabel">Specified by:</span></dt>
<dd><code><a href="UserDetails.html#getUsername()">getUsername</a></code>&nbsp;in interface&nbsp;<code><a href="UserDetails.html" title="interface in org.springframework.security.core.userdetails">UserDetails</a></code></dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>the username (never <code>null</code>)</dd>
</dl>
</li>
</ul>
<a id="isEnabled()">

</a>
<ul class="blockList">
<li class="blockList">
<h4>isEnabled</h4>
<pre class="methodSignature">public&nbsp;boolean&nbsp;isEnabled()</pre>
<div class="block"><span class="descfrmTypeLabel">Description copied from interface:&nbsp;<code><a href="UserDetails.html#isEnabled()">UserDetails</a></code></span></div>
<div class="block">Indicates whether the user is enabled or disabled. A disabled user cannot be
authenticated.</div>
<dl>
<dt><span class="overrideSpecifyLabel">Specified by:</span></dt>
<dd><code><a href="UserDetails.html#isEnabled()">isEnabled</a></code>&nbsp;in interface&nbsp;<code><a href="UserDetails.html" title="interface in org.springframework.security.core.userdetails">UserDetails</a></code></dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd><code>true</code> if the user is enabled, <code>false</code> otherwise</dd>
</dl>
</li>
</ul>
<a id="isAccountNonExpired()">

</a>
<ul class="blockList">
<li class="blockList">
<h4>isAccountNonExpired</h4>
<pre class="methodSignature">public&nbsp;boolean&nbsp;isAccountNonExpired()</pre>
<div class="block"><span class="descfrmTypeLabel">Description copied from interface:&nbsp;<code><a href="UserDetails.html#isAccountNonExpired()">UserDetails</a></code></span></div>
<div class="block">Indicates whether the user's account has expired. An expired account cannot be
authenticated.</div>
<dl>
<dt><span class="overrideSpecifyLabel">Specified by:</span></dt>
<dd><code><a href="UserDetails.html#isAccountNonExpired()">isAccountNonExpired</a></code>&nbsp;in interface&nbsp;<code><a href="UserDetails.html" title="interface in org.springframework.security.core.userdetails">UserDetails</a></code></dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd><code>true</code> if the user's account is valid (ie non-expired),
<code>false</code> if no longer valid (ie expired)</dd>
</dl>
</li>
</ul>
<a id="isAccountNonLocked()">

</a>
<ul class="blockList">
<li class="blockList">
<h4>isAccountNonLocked</h4>
<pre class="methodSignature">public&nbsp;boolean&nbsp;isAccountNonLocked()</pre>
<div class="block"><span class="descfrmTypeLabel">Description copied from interface:&nbsp;<code><a href="UserDetails.html#isAccountNonLocked()">UserDetails</a></code></span></div>
<div class="block">Indicates whether the user is locked or unlocked. A locked user cannot be
authenticated.</div>
<dl>
<dt><span class="overrideSpecifyLabel">Specified by:</span></dt>
<dd><code><a href="UserDetails.html#isAccountNonLocked()">isAccountNonLocked</a></code>&nbsp;in interface&nbsp;<code><a href="UserDetails.html" title="interface in org.springframework.security.core.userdetails">UserDetails</a></code></dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd><code>true</code> if the user is not locked, <code>false</code> otherwise</dd>
</dl>
</li>
</ul>
<a id="isCredentialsNonExpired()">

</a>
<ul class="blockList">
<li class="blockList">
<h4>isCredentialsNonExpired</h4>
<pre class="methodSignature">public&nbsp;boolean&nbsp;isCredentialsNonExpired()</pre>
<div class="block"><span class="descfrmTypeLabel">Description copied from interface:&nbsp;<code><a href="UserDetails.html#isCredentialsNonExpired()">UserDetails</a></code></span></div>
<div class="block">Indicates whether the user's credentials (password) has expired. Expired
credentials prevent authentication.</div>
<dl>
<dt><span class="overrideSpecifyLabel">Specified by:</span></dt>
<dd><code><a href="UserDetails.html#isCredentialsNonExpired()">isCredentialsNonExpired</a></code>&nbsp;in interface&nbsp;<code><a href="UserDetails.html" title="interface in org.springframework.security.core.userdetails">UserDetails</a></code></dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd><code>true</code> if the user's credentials are valid (ie non-expired),
<code>false</code> if no longer valid (ie expired)</dd>
</dl>
</li>
</ul>
<a id="eraseCredentials()">

</a>
<ul class="blockList">
<li class="blockList">
<h4>eraseCredentials</h4>
<pre class="methodSignature">public&nbsp;void&nbsp;eraseCredentials()</pre>
<dl>
<dt><span class="overrideSpecifyLabel">Specified by:</span></dt>
<dd><code><a href="../CredentialsContainer.html#eraseCredentials()">eraseCredentials</a></code>&nbsp;in interface&nbsp;<code><a href="../CredentialsContainer.html" title="interface in org.springframework.security.core">CredentialsContainer</a></code></dd>
</dl>
</li>
</ul>
<a id="equals(java.lang.Object)">

</a>
<ul class="blockList">
<li class="blockList">
<h4>equals</h4>
<pre class="methodSignature">public&nbsp;boolean&nbsp;equals&#8203;(java.lang.Object&nbsp;obj)</pre>
<div class="block">Returns <code>true</code> if the supplied object is a <code>User</code> instance with the
same <code>username</code> value.
<p>
In other words, the objects are equal if they have the same username, representing
the same principal.</div>
<dl>
<dt><span class="overrideSpecifyLabel">Overrides:</span></dt>
<dd><code>equals</code>&nbsp;in class&nbsp;<code>java.lang.Object</code></dd>
</dl>
</li>
</ul>
<a id="hashCode()">

</a>
<ul class="blockList">
<li class="blockList">
<h4>hashCode</h4>
<pre class="methodSignature">public&nbsp;int&nbsp;hashCode()</pre>
<div class="block">Returns the hashcode of the <code>username</code>.</div>
<dl>
<dt><span class="overrideSpecifyLabel">Overrides:</span></dt>
<dd><code>hashCode</code>&nbsp;in class&nbsp;<code>java.lang.Object</code></dd>
</dl>
</li>
</ul>
<a id="toString()">

</a>
<ul class="blockList">
<li class="blockList">
<h4>toString</h4>
<pre class="methodSignature">public&nbsp;java.lang.String&nbsp;toString()</pre>
<dl>
<dt><span class="overrideSpecifyLabel">Overrides:</span></dt>
<dd><code>toString</code>&nbsp;in class&nbsp;<code>java.lang.Object</code></dd>
</dl>
</li>
</ul>
<a id="withUsername(java.lang.String)">

</a>
<ul class="blockList">
<li class="blockList">
<h4>withUsername</h4>
<pre class="methodSignature">public static&nbsp;<a href="User.UserBuilder.html" title="class in org.springframework.security.core.userdetails">User.UserBuilder</a>&nbsp;withUsername&#8203;(java.lang.String&nbsp;username)</pre>
<div class="block">Creates a UserBuilder with a specified user name</div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>username</code> - the username to use</dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>the UserBuilder</dd>
</dl>
</li>
</ul>
<a id="builder()">

</a>
<ul class="blockList">
<li class="blockList">
<h4>builder</h4>
<pre class="methodSignature">public static&nbsp;<a href="User.UserBuilder.html" title="class in org.springframework.security.core.userdetails">User.UserBuilder</a>&nbsp;builder()</pre>
<div class="block">Creates a UserBuilder</div>
<dl>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>the UserBuilder</dd>
</dl>
</li>
</ul>
<a id="withDefaultPasswordEncoder()">

</a>
<ul class="blockList">
<li class="blockList">
<h4>withDefaultPasswordEncoder</h4>
<pre class="methodSignature">@Deprecated
public static&nbsp;<a href="User.UserBuilder.html" title="class in org.springframework.security.core.userdetails">User.UserBuilder</a>&nbsp;withDefaultPasswordEncoder()</pre>
<div class="deprecationBlock"><span class="deprecatedLabel">Deprecated.</span>
<div class="deprecationComment">Using this method is not considered safe for production, but is
acceptable for demos and getting started. For production purposes, ensure the
password is encoded externally. See the method Javadoc for additional details.
There are no plans to remove this support. It is deprecated to indicate that this
is considered insecure for production purposes.</div>
</div>
<div class="block"><p>
<b>WARNING:</b> This method is considered unsafe for production and is only
intended for sample applications.
</p>
<p>
Creates a user and automatically encodes the provided password using
<code>PasswordEncoderFactories.createDelegatingPasswordEncoder()</code>. For example:
</p>
<pre> <code>
 UserDetails user = User.withDefaultPasswordEncoder()
     .username("user")
     .password("password")
     .roles("USER")
     .build();
 // outputs {bcrypt}$2a$10$dXJ3SW6G7P50lGmMkkmwe.20cQQubK3.HZWzG3YB1tlRy.fqvM/BG
 System.out.println(user.getPassword());
 </code> </pre>
This is not safe for production (it is intended for getting started experience)
because the password "password" is compiled into the source code and then is
included in memory at the time of creation. This means there are still ways to
recover the plain text password making it unsafe. It does provide a slight
improvement to using plain text passwords since the UserDetails password is
securely hashed. This means if the UserDetails password is accidentally exposed,
the password is securely stored.
In a production setting, it is recommended to hash the password ahead of time. For
example:
<pre> <code>
 PasswordEncoder encoder = PasswordEncoderFactories.createDelegatingPasswordEncoder();
 // outputs {bcrypt}$2a$10$dXJ3SW6G7P50lGmMkkmwe.20cQQubK3.HZWzG3YB1tlRy.fqvM/BG
 // remember the password that is printed out and use in the next step
 System.out.println(encoder.encode("password"));
 </code> </pre>
<pre> <code>
 UserDetails user = User.withUsername("user")
     .password("{bcrypt}$2a$10$dXJ3SW6G7P50lGmMkkmwe.20cQQubK3.HZWzG3YB1tlRy.fqvM/BG")
     .roles("USER")
     .build();
 </code> </pre></div>
<dl>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>a UserBuilder that automatically encodes the password with the default
PasswordEncoder</dd>
</dl>
</li>
</ul>
<a id="withUserDetails(org.springframework.security.core.userdetails.UserDetails)">

</a>
<ul class="blockListLast">
<li class="blockList">
<h4>withUserDetails</h4>
<pre class="methodSignature">public static&nbsp;<a href="User.UserBuilder.html" title="class in org.springframework.security.core.userdetails">User.UserBuilder</a>&nbsp;withUserDetails&#8203;(<a href="UserDetails.html" title="interface in org.springframework.security.core.userdetails">UserDetails</a>&nbsp;userDetails)</pre>
</li>
</ul>
</li>
</ul>
</section>
</li>
</ul>
</div>
</div>
</main>

<footer role="contentinfo">
<nav role="navigation">

<div class="bottomNav"><a id="navbar.bottom">

</a>
<div class="skipNav"><a href="User.html#skip.navbar.bottom" title="Skip navigation links">Skip navigation links</a></div>
<a id="navbar.bottom.firstrow">

</a>
<ul class="navList" title="Navigation">
<li><a href="../../../../../index.html">Overview</a></li>
<li><a href="package-summary.html">Package</a></li>
<li class="navBarCell1Rev">Class</li>
<li><a href="package-tree.html">Tree</a></li>
<li><a href="../../../../../deprecated-list.html">Deprecated</a></li>
<li><a href="../../../../../index-all.html">Index</a></li>
<li><a href="../../../../../help-doc.html">Help</a></li>
</ul>
</div>
<div class="subNav">
<ul class="navList" id="allclasses_navbar_bottom">
<li><a href="../../../../../allclasses.html">All&nbsp;Classes</a></li>
</ul>
<div>
<script type="text/javascript"><!--
  allClassesLink = document.getElementById("allclasses_navbar_bottom");
  if(window==top) {
    allClassesLink.style.display = "block";
  }
  else {
    allClassesLink.style.display = "none";
  }
  //-->
</script>
<noscript>
<div>JavaScript is disabled on your browser.</div>
</noscript>
</div>
<div>
<ul class="subNavList">
<li>Summary:&nbsp;</li>
<li><a href="User.html#nested.class.summary">Nested</a>&nbsp;|&nbsp;</li>
<li>Field&nbsp;|&nbsp;</li>
<li><a href="User.html#constructor.summary">Constr</a>&nbsp;|&nbsp;</li>
<li><a href="User.html#method.summary">Method</a></li>
</ul>
<ul class="subNavList">
<li>Detail:&nbsp;</li>
<li>Field&nbsp;|&nbsp;</li>
<li><a href="User.html#constructor.detail">Constr</a>&nbsp;|&nbsp;</li>
<li><a href="User.html#method.detail">Method</a></li>
</ul>
</div>
<a id="skip.navbar.bottom">

</a></div>

</nav>
</footer>
<script>if (window.parent == window) {(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o), m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)})(window,document,'script','//www.google-analytics.com/analytics.js','ga');ga('create', 'UA-2728886-23', 'auto', {'siteSpeedSampleRate': 100});ga('send', 'pageview');}</script><script defer src="https://static.cloudflareinsights.com/beacon.min.js/v652eace1692a40cfa3763df669d7439c1639079717194" integrity="sha512-Gi7xpJR8tSkrpF7aordPZQlW2DLtzUlZcumS8dMQjwDHEnw9I7ZLyiOj/6tZStRBGtGgN6ceN6cMH8z7etPGlw==" data-cf-beacon='{"rayId":"7040f386de6297cf","token":"bffcb8a918ae4755926f76178bfbd26b","version":"2021.12.0","si":100}' crossorigin="anonymous"></script>
</body>
</html>
